import java.awt.Button;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.util.ArrayList;

import javax.management.monitor.Monitor;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class ledOverview extends JPanel{

	final static int amb=0, str=1, colm=2;
	int width, height, LEDsizeX,LEDsizeY;
	int[][] leds;
	Color color;
	ArrayList<int[]> lista;

	JFrame Frame;
	JPanel Panel;
	Button button1;
	Button button2;

	int LEDwidth = 50;
	JPanel[] LED;
	GridLayout lay;
	Comm com;
	modeMon mon;
	
	Image img;

	ArrayList<Color> colorlist;
	public ledOverview(int width, int height, int[][] led, Comm com, modeMon mon){
		leds=led;
		this.mon=mon;
		this.setBackground(Color.BLACK);
		this.width=width;
		this.height=height;
		this.com=com;
		LEDsizeX=width/9;
		LEDsizeY=height/20;
		com.setLEDView(this);
		
		img = new ImageIcon(getClass().getResource("led.jpg")).getImage();

		lista = new ArrayList<int[]>();
		colorlist = new ArrayList<Color>();
		for(int i=0; i<leds.length; i++) {
			int x = leds[i][1];
			int y = leds[i][2];

			int[] coord = {x*LEDsizeX,y*LEDsizeY};
			lista.add(coord);
		}
	}


	public void paintComponent(Graphics g){
		super.paintComponent(g);
		
		for(int i=0; i<leds.length; i++) {
			try {
				colorlist = mon.getColor();
				Color c = colorlist.get(i);
				g.setColor(c);

			} catch (Exception e) {
			}
			int[] coord = lista.get(i);

			g.fillRect(coord[0], coord[1], LEDsizeX, LEDsizeY);
			g.setColor(Color.CYAN);
			g.drawString("nr " + (i+1), coord[0], coord[1]+10);
			
			g.drawImage(img, LEDwidth, 40, null);
		}
	}
	
	public void Repaint(){
		repaint();
		GUI.setColorChooser(mon.getSolidColor());
	}


}
